package gem.model.dao.mysql;

import gem.model.core.*;
import gem.model.dao.CourseDAO;
import gem.model.dao.DAOFactory;
import gem.model.dao.DepartmentDAO;
import gem.model.dao.ScienceDomainDAO;

public class MySqlDAOFactory extends DAOFactory
{

    public static final String jdbcDriver = "com.mysql.jdbc.Driver";
    public static final String jdbcURL = "jdbc:mysql://localhost/gem?user=root&password=test&characterSetResults=UTF-8&characterEncoding=UTF8&useUnicode=true";
    private MySqlDepartmentDAO depDAO = null;
    private MySqlScienceDomainDAO sdDAO = null;
    private MySqlCourseDAO cDAO = null;
    
    private static MySqlDAOFactory mysqlFac = null;

    public static MySqlDAOFactory getInstance()
    {
        if( mysqlFac == null )
        {
            mysqlFac = new MySqlDAOFactory();
        }
        return mysqlFac;
    }

    private MySqlDAOFactory()
    {
        
    }

    private Department defaultDepartment = null;
    private ScienceDomain defaultScienceDomain = null;
    private Course defaultCourse = null;

    public Department getDefaultDepartment()
    {
        if( defaultDepartment == null )
        {            
            
        }
        return defaultDepartment;
    }

    public ScienceDomain getDefaultScienceDomain()
    {
        if( defaultScienceDomain == null )
        {

        }
        return defaultScienceDomain;
    }

    public Course getDefaultCourse()
    {
        if( defaultCourse == null )
        {

        }
        return defaultCourse;
    }
	
    java.sql.Connection getConnection()
    {
        // TODO: from pool, fetch connection
        return null;
    }

    @Override
    public CourseDAO getCourseDAO()
    {
        if (cDAO == null)
        {
            cDAO = new MySqlCourseDAO();
        }
        return cDAO;
    }

    @Override
    public ScienceDomainDAO getScienceDomainDAO()
    {
        if (sdDAO == null)
        {
            sdDAO = new MySqlScienceDomainDAO();
        }
        return sdDAO;
    }

    @Override
    public DepartmentDAO getDepartmentDAO()
    {
        if (depDAO == null)
        {
            depDAO = new MySqlDepartmentDAO();
        }
        return depDAO;
    }

}
